package cn.mesmile.nacos.model;

import cn.hutool.core.date.DateUtil;
import cn.mesmile.nacos.dto.Datas;
import cn.mesmile.nacos.dto.StatisticalResults;
import com.alibaba.fastjson.JSONObject;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zb
 * @date 2021/6/18 23:42
 * @Description:
 */
public class TestStrtegy {

    public static void main(String[] args) {
        StatisticsContext context = null;

        List<Datas> datas = new ArrayList<>();
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-16 7:12:23"), "123456"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-16 8:12:23"), "123456"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-16 8:23:23"), "12345678"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-17 8:45:23"), "12345678"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-17 10:12:23"), "123456"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-19 12:10:23"), "123456"));
        datas.add( new Datas(DateUtil.parseDateTime("2021-6-19 12:12:23"), "123456"));

        // 执行查询今日数据
//        TodayData todayData = new TodayData();
//        context = new StatisticsContext(todayData);
//        StatisticalResults statisticalResults = context.executeStrategy(datas);
//        String s = JSONObject.toJSONString(statisticalResults);
//        System.out.println(s);

        // 查询本周
        ThisWeekData thisWeekData = new ThisWeekData();
        context = new StatisticsContext(thisWeekData);
        StatisticalResults statisticalResults = context.executeStrategy(datas);
        String s = JSONObject.toJSONString(statisticalResults);
        System.out.println(s);


    }
}
